#ifndef __TRANSFILE__H__
#define __TRANSFILE__H__

#include"head.h"
#include "taskqueue.h"

typedef struct train_s
{
    int len;
    char data[1024];
}train_t;

//文件传输队列
typedef struct file_s
{
    int peerfd;
    int fileSys;//是否已经同步文件传输的进度
    int fileSize;//文件大小
    int fileRecvSize;//已发送大小
    char md5[33];
    int md5Sys;
    char filename[100];
    int endRecv;
    struct file_s* next;
}file_t,*pfile_t;

typedef struct fileque_s
{
    file_t* front;
    file_t* rear;
    int length;//队列长度
    pthread_mutex_t mutex;//锁
    pthread_cond_t cond;//条件变量
}fileQue,*pfileQue;


void InitFileque(pfileQue fileque);
void DestroyFileque(pfileQue fileque);
void FilequeEnque(pfileQue fileque,pfile_t pfileNode);
void FilequeDeque(pfileQue fileque,pfile_t pfileNode);
void FilequeRecoverque(pfileQue fileque, pfile_t pfileNode);
void AddfilequeNode(pfileQue fileque,int peerfd);
pfile_t findNode(int peerfd,pfileQue fileque);


task_t* recvCmd(int peerfd);
int recvCircle(int fd, char * buff, int length);

#endif
